<template>
    <div class="container" v-loading="loading">
        <div class="stu-header" transiton="fade">
            <div>
                <div  style="display:flex; align-items: center; ">
                    <div class="export_icon" @click.stop="openDrawer">
                        <img src="../../../../../assets/img/search_icon.png" alt="">
                        <el-button link type="primary" size="small">筛选项</el-button>
                    </div>
                    <span v-if="searchForm.queryShow" style="display: flex;align-items: center;">
                        <div class="export_icon" style="margin-left: 15px;" @click="getDataList(1)">
                            <img src="../../../../../assets/img/excel_icon.png" alt="">
                            <el-button link type="primary" size="small">导出表格</el-button>
                        </div>
                        <div style="display: flex;flex-direction: row;align-items: center;">
                            <span class="mtitle-color mtitle-font" style="margin: 0 0 0 40px;">当前查询批次</span>
                            <div style="display: flex;flex-direction: row;">
                                <div class="lie-title nine-line-title" style="margin-left: 20px;">查询批次：</div>
                                <span class="mtitle-color mtitle-font">{{dataList.testAName || '无'}}</span>
                            </div>
                            <div style="display: flex;flex-direction: row;" v-if="searchForm.queryTypes=='a4'">
                                <div class="lie-title nine-line-title" style="margin-left: 20px;">对比批次：</div>
                                <span class="mtitle-color mtitle-font">{{dataList.testBName || '无'}}</span>
                            </div>
                        </div>
                        <span class="htitle-color e_phic" style="margin-left: 30px;">说明：年级数据的取值均根据：查询项“年级数据范围”取值。</span>
                    </span>
                </div>               
                <div class="box-p-pre" v-if="!searchForm.queryShow">
                    <div class="stitle-font error-color" style="margin: 20px 0 0 60px;">点击上方“筛选项”进行查询成绩数据。</div>
                </div> 
               
            </div>                      
        </div>
        <div class="con" v-if="searchForm.queryShow">
            <div class="query_con" >
                <div class="nine-form-title" label="" prop="subjectId" v-if="searchForm.queryTypes != 'a3' && searchForm.queryTypes != 'a5'">
                    <el-radio-group v-model="searchForm.subjectId" @change="getDataList">
                        <el-radio-button  :label="item.id" name="subjectId" v-for="item in queryListAll['subjectList']" :key="item.id">{{item.name}}</el-radio-button>
                    </el-radio-group>
                </div>
                <div class="nine-form-title" label="" prop="scoreType" v-if="searchForm.queryTypes == 'a3'">
                    <el-radio-group v-model="searchForm.scoreType" @change="getDataList()">
                        <el-radio-button :label="0" name="scoreType">原始分</el-radio-button>
                        <el-radio-button :label="1" name="scoreType">等级分</el-radio-button>
                    </el-radio-group>
                </div>
            </div> 
            <class-sum-1 :dataList="dataList" :searchForm="searchForm" :searchForms1="searchForms1" v-if="searchForm.queryTypes=='a1'" @classTo1="classTo1"></class-sum-1>  
            <online-num-2 :dataList="dataList" :searchForm="searchForm" v-if="searchForm.queryTypes=='a2'" @classTo1="classTo1"></online-num-2>
            <avg-score-3 :dataList="dataList" :searchForm="searchForm" :searchForms1="searchForms1" v-if="searchForm.queryTypes=='a3'" @classTo1="classTo1"></avg-score-3>
            <compare-last-4 :dataList="dataList" :searchForm="searchForm" :searchForms1="searchForms1" v-if="searchForm.queryTypes=='a4'" @classTo1="classTo1" @toStuComDetails="toStuComDetails"></compare-last-4>
           <!--  <class-balance-5 :dataList="dataList" :searchForm="searchForm" v-if="searchForm.queryTypes=='a5'" @classTo1="classTo1"></class-balance-5>
            <class-level-6 :dataList="dataList" :searchForm="searchForm" :searchForms1="searchForms1" v-if="searchForm.queryTypes=='a6'" @classTo1="classTo1"></class-level-6> -->
        </div>
        <el-drawer title="筛选项" v-model="isSearchAll" :direction="direction" :before-close="(()=>{isSearchAll=false})" size="50%">
            <div class="el-dialog-div">
                <el-form :inline="true" class="demo-form-inline filter_search" :model="searchForm" label-position="right"
                    label-width="120px" :rules="searchRules" ref="searchRulesRef">
                    <div class="option_title">查询范围</div>
                    <div>
                        <el-form-item class="nine-form-title" prop="grade" label="年级">
                            <el-select placeholder="请选择"  v-model="searchForm.grade" @change="getPermissionArea('areaId')">
                                <el-option  v-for="(item, index) in queryListAll['gradeList']" :key="index" :label="item.name" :value="item.id"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item class="nine-form-title" prop="areaId" label="上课校区">
                            <el-select v-model="searchForm.areaId" placeholder="请选择" :clearable="queryListAll['areaList'] && queryListAll['areaList'].length!=1" @change="getPermissionArea()">
                                <el-option  v-for="(item, index) in queryListAll['areaList']" :key="index" :label="item.name" :value="item.id"></el-option>
                            </el-select>
                        </el-form-item>
                    </div>
                    <div>
                        <el-form-item class="nine-form-title" prop="dataRange" label="年级数据范围">
                           <!--  <el-select placeholder="请选择"  v-model="searchForm.dataRange" clearable>
                                <el-option  label="精华整体" value="null"></el-option>
                                <el-option  label="民办校整体" :value="1"></el-option>
                                <el-option  label="高考全日制整体" :value="0"></el-option>
                            </el-select> -->
                            <el-select placeholder="请选择"  v-model="searchForm.dataRange">
                                <el-option  v-for="(item, index) in queryListAll['dataRange']" :key="index" :label="item.name" :value="item.id"></el-option>
                            </el-select>
                        </el-form-item>

                      <!--   <el-form-item class="nine-form-title" label="补考/缺考" prop="noIncludelackTest">
                            <el-select v-model="searchForm.noIncludelackTest" clearable placeholder="请选择">
                                <el-option :key='2' :value="2" label="补考生"></el-option>
                                <el-option :key='1' :value="1" label="缺考生"></el-option>
                                <el-option :key='3' :value="3" label="不含补考"></el-option>
                                <el-option :key='4' :value="4" label="不含缺考"></el-option>
                                <el-option :key='5' :value="5" label="不含补考/缺考"></el-option>
                            </el-select>
                        </el-form-item> -->
                        <el-form-item class="nine-form-title" label="不包含" prop="noIncludelackTest" style="display: flex;">
                            <el-checkbox-group v-model="searchForm.noIncludelackTest">
                                <el-checkbox :label="1" >缺考</el-checkbox>
                                <el-checkbox :label="2" >精华补考</el-checkbox>
                                <el-checkbox :label="3" >原校参考</el-checkbox>
                            </el-checkbox-group>
                        </el-form-item>
                    </div>
                    <div class="option_title">考试批次</div>
                    <div>
                        <el-form-item class="nine-form-title" label="学年" prop="yearly">
                            <el-select
                                v-model="searchForm.yearly" placeholder="请选择" value-key="yearly" @change="handlerYearChange">
                                <el-option v-for="item in yearlist" :key="item.value" :label="item.key" :value="item.value"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item class="nine-form-title" label="考试批次" prop="testIdA">
                            <el-select
                                v-model="searchForm.testIdA" style="100%" placeholder="请选择"
                                value-key="testIdA">
                                <el-option
                                    v-for="item in kspcList"
                                    :key="item.testId"
                                    :label="item.simpleName"
                                    :value="item.testId"
                                >
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </div> 
                    <div class="option_title">数据维度</div>
                    <div>
                        <el-form-item class="nine-form-title week_radio" label="查询维度" prop="queryType" style="display: flex;">
                            <el-radio-group v-model="searchForm.queryType">
                                <el-radio :label="1" name="queryType">班级汇总</el-radio>
                                <el-radio :label="5" name="queryType" v-if="searchForm.grade!='17' && searchForm.grade!='14'">班级科目均衡性</el-radio>
                                <el-radio :label="2" name="queryType">上线人数</el-radio>
                                <el-radio :label="3" name="queryType">平均分</el-radio>
                                <el-radio :label="6" name="queryType">优秀/合格率</el-radio>
                                <el-radio :label="4" name="queryType">与上次对比</el-radio>
                            </el-radio-group>
                        </el-form-item>
                    </div>
                    <div>
                        <el-form-item class="nine-form-title" label="对比批次" prop="testIdB" v-if="searchForm.queryType==4">
                            <el-select
                                v-model="searchForm.testIdB" style="100%" placeholder="请选择"
                                value-key="testIdB">
                                <el-option
                                    v-for="item in kspcList"
                                    :key="item.testId"
                                    :label="item.simpleName"
                                    :value="item.testId"
                                >
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </div>
                </el-form>
            </div>
            <div class="dialog-footer" style="text-align: center;margin: 30px 0px;">
                <!-- 分支测试提交 -->
                <el-button type="primary" @click="getDataList">筛选</el-button>               
            </div>
        </el-drawer>
    </div>
</template>
<script setup name="classResultAnalysis">
import qs from 'qs';
import { baseUrl } from '@/utils/api';
import classSum1 from './class_sum_1.vue';
import onlineNum2 from './online_num_2.vue';
import avgScore3 from './avg_score_3.vue';
import compareLast4 from './compare_last_4/compare_last_4.vue';
// import classBalance5 from './class_balance_5.vue';
// import classLevel6 from './class_level_6.vue';
import { reactive, ref, computed, getCurrentInstance, nextTick, onMounted, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useStore } from 'vuex';
function downFile(blob, fileName) {
    if (window.navigator.msSaveOrOpenBlob) {
      navigator.msSaveBlob(blob, fileName);
    } else {
      var link = document.createElement('a');
      link.href = window.URL.createObjectURL(blob);
      link.download = fileName;
      link.click();
      window.URL.revokeObjectURL(link.href);
    }
}
let router = useRouter();
let route = useRoute();
let store = useStore();
let { proxy }= getCurrentInstance();
let loading = ref(false);
let searchForms1= reactive({});
let direction=ref('ltr');//筛选项方向
let isSearchAll=ref(false);
let isDel=ref(false);
let dataList= reactive({
    classNumList: []
});
let searchForm=reactive({
    yearly: '',
    areaId: "",
    noIncludelackTest: [],
    testIdA: '',
    testIdB: '',
    grade: '',
    grades: '',
    queryShow: false,//是否筛选
    subjectId: '',
    queryType: 1,
    queryTypes: '',
    scoreType: 0,
    scoreTypes: 'a0',
    dataRange: '',
});
let searchRules= reactive({
    grade: [{required: true, message: '请选择年级', trigger: 'change'}],
    dataRange: [{required: true, message: '请选择年级数据范围', trigger: 'change'}],
    yearly: [{required: true, message: '请选择学年', trigger: 'change'}],
    testIdA: [{required: true, message: '请选择考试批次', trigger: 'change'}],
    testIdB: [{required: true, message: '请选择对比批次', trigger: 'change'}],
    queryType: [{required: true, message: '请选择查询维度', trigger: 'change'}],
});
let subjectList=reactive(
    [
        {id: 100,name: '总分'},
        {id: 101,name: '语文'},
        {id: 102,name: '数学'},
        {id: 103,name: '英语'},
        {id: 104,name: '物理'},
        {id: 105,name: '化学'},
        {id: 106,name: '生物'},
        {id: 107,name: '历史'},
        {id: 108,name: '地理'},
        {id: 109,name: '政治'}
    ]
);
let yearlist=reactive([]);//学年列表
let kspcList=reactive([]);
let areaList=reactive([]);
let menuParams=reactive({});//菜单参数
let userInfo=reactive({});
let queryListAll=reactive({//所有查询列表
    areaList: []
});
const searchRulesRef = ref(null);
//打开查询项
let openDrawer=()=>{
    isSearchAll.value=true;
};
let getDataList=(searchExport)=>{  
    let findIndex = queryListAll['subjectList'].findIndex((item)=>{ return item.id ==searchForm.subjectId});
    if(findIndex>=0){//当前学年                    
        searchForm.subjectName = queryListAll['subjectList'][findIndex].name;
    }
    
    let exportObj ={};
    if(searchExport==1){
        // downloadType 下载类型，1为下载，其他为查询
        exportObj ={responseType: 'blob'};
        searchForm['downloadType'] = 1;
    }else{
        searchForm['downloadType'] = 2;
    }
    let httpUrl = '/ft/score/analysis/classScoreAnalysis.do';
    searchRulesRef.value.validate((valid) => {
        if(valid){
            isSearchAll.value = false;
            loading.value = true;  
            let param = new URLSearchParams();
            let datas = JSON.parse(JSON.stringify(searchForm));
            datas.dataRange = datas.dataRange == "null" ? null : datas.dataRange;
            datas.noIncludelackTest = datas.noIncludelackTest.join(",");
            let newParam = paramIsNull(datas);
                Object.keys(newParam).forEach(function(key){
                param.append(key, newParam[key]);
            }) 
            param.append('isMaster', queryListAll['isMaster']);
            if(!searchForm.classIds){
                let classIds = [];
                if(queryListAll['masterOrTeacherList'] && queryListAll['masterOrTeacherList'].length){//没选择班级，默认传全部
                    queryListAll['masterOrTeacherList'].forEach(item=>{
                        classIds.push(item.id);
                    })
                }
                // classIds.push(36161);
                param.append('classIds', classIds.join(','));
            }else{
                param.append("classIds", searchForm.classIds ||'');
            }
            proxy.$post(baseUrl + httpUrl, param,exportObj)
                .then(res=>{
                    loading.value = false;
                    if(searchExport==1){//导出       
                        let headerContent = res.headers['content-disposition'];   
                        if(headerContent){
                            let filenameStr = headerContent.split('=')[1];
                            let blobobj = new Blob([res.data],{type:'application/vnd.ms-excel'});
                            downFile(blobobj, decodeURI(filenameStr));
                        }
                    }else{//查询
                        if(res.data.code != 0){   
                            return proxy.$message.error(res.data.msg);
                        }
                        dataList = res.data.data;
                        if(JSON.stringify(dataList) == "{}"){
                            dataList = initList();
                        }
                        showTableColumn();
                        hidePopover();
                    }

                })
        }else{
            this.$message.error('请输入必填项！');
            return false;
        }
    });
};
//参数是否为空值校验
let paramIsNull=(obj)=>{
    // 浅拷贝
    var obj2 = {...obj};
    Object.keys(obj2).forEach((key) => {
        if ((obj2[key]&&obj2[key].constructor==Array) ||obj2[key] === undefined || obj2[key] === null || obj2[key] === '' || JSON.stringify(obj2[key]) ==='[Object Object]') {
            delete obj2[key];
        }
    });
    return obj2;
};
let initList=()=>{
    let datas = {};
    switch (searchForm.queryType){
        case 1:
            datas={
                avgMap: {maxScore: 0, className: [], scoreList: []},
                classNumList: {classList: [], gradeList: []},
                disTableList: {},
                xxtMap: {}
            }

        break;
        case 2:
            datas={
                bareaPercent: {},
                bjhLine: {},
                lareaPercent: {},
                ljhLine: {}
            }

        break;
        case 3:
            datas={
                bioRank: [],
                cmeRank: [],
                geoRank: [],
                hisRank: [],
                mainList: [],
                phyRank: [],
                polRank: []
            }

        break;
        case 4:
            datas={
                analyList: {classList: [], gradeList: []},
                progressRate:{classList: [], gradeList: []}
            }
        break;
        case 5:
        break;
    }
    return datas;
};
let handleClose=(val)=>{
    isSearchAll.value = false;
};
/**
 * 表格显示列
 */
let showTableColumn=()=>{
    let arr = ['queryType', 'grade','scoreType','subjectId'];
    searchForm.queryShow = true;
    arr.forEach(item=>{
        if(searchForm[item]){
            searchForm[item+'s'] = 'a' +searchForm[item];
        }
        if(searchForm[item] == ''){
            searchForm[item+'s'] = '';
        }
    })
    searchForms1 = JSON.parse(JSON.stringify(searchForm));
    console.log(searchForms1,'----')
};
//滑动表格 隐藏 popover
let hidePopover=()=>{
    nextTick(() => {
        let scroll = document.querySelectorAll("div[class='content'],.el-table .el-table__body-wrapper");
        if (scroll && scroll.length) {      
            scroll.forEach((item)=>{
                // 监听这个dom的scroll事件
                item.addEventListener('scroll', () => {
                    //首先把下拉框下拉的东西清掉
                    let nowEle = document.activeElement;                     
                    let select = nowEle.parentNode.parentNode.parentNode;
                    if (select) {                            
                        let pops = document.querySelectorAll(".el-select-dropdown.el-popper,.el-select.el-popper,.el-popover");
                        if (pops.length > 0) {
                            for (let item in pops) {                                  
                                if (pops[item] && pops[item].style && pops[item].style.display != 'none') {
                                    pops[item].style.display = 'none'
                                    nowEle.click();
                                }
                            }
                        }
                    }
                }, false)            
            })    
        }
    })
};
let getSessionSearch=async ()=>{
    let search = JSON.parse(window.sessionStorage.getItem("vuex"))
    if(JSON.stringify(search.classResultAnalysis.menuParams)!='{}'){
        menuParams = {...menuParams, ...search.classResultAnalysis.menuParams};
    }    
    await getYears();
    await getUserInfo();
};
onMounted(()=>{
    getSessionSearch();
})
//回车关闭筛选框
let keyupEnter=()=>{
    document.onkeydown = (e) =>{
        let body = document.getElementsByTagName('body')[0]
        if (e.keyCode === 13 && e.target.baseURI.match(/classResultAnalysis/)) {
            // console.log('enter')
            if(isSearchAll.value){
                getDataList(); 
                //首先把下拉框下拉的东西清掉
                let nowEle = document.activeElement;       
                let pops = document.querySelectorAll(".el-select-dropdown.el-popper,.el-select.el-popper");
                if (pops.length > 0) {
                    for (let item in pops) {                                  
                        if (pops[item] && pops[item].style && pops[item].style.display != 'none') {
                            pops[item].style.display = 'none'
                            nowEle.click();
                        }
                    }
                }                    
            }
            return false;
        }
    }
};
/**
 * 班级看板
 */
let classTo1=(params)=>{
    isDel.value = true;
    store.commit('classBoard/setRouteParams', params);
    router.push({
        name:'classBoard',
        params: params
    })
};
/**
 *与上次对比 - 学生对比详情
* @param routerName 跳转路由的名字
* @param type 1原始分 2等级分 学生详情
*/
let toStuComDetails=(params)=>{
    isDel.value = true;
    store.commit(`${params['routerName']}/setRouteParams`, params);
    router.push({
        name:`${params['routerName']}`,
        params: params
    })
};
//获取用户信息
let getUserInfo=()=>{
    proxy.$get(baseUrl+'/ft/ftchoose/getUserInfo.do')
        .then(res => {
            if(res.data.code !==0){
                return proxy.$message.error(res.data.msg);
            }
            userInfo = res.data || {};
            getPermissionArea();
    }, err => {
        proxy.$message.error(err);
    });
};
/**
 * 改变学年级联批次
 */
let handlerYearChange=(val)=>{
    if(!val){
        searchForm.yearly = '';
    }
    searchForm.testIdA = '';
    searchForm.testIdB = '';
    getKspcList(); //考试批次
    getPermissionArea('testId');
};
/**
 * 获取所有查询列表数据
 * @functionId 菜单id
 * @roleId 角色id
 */
let getPermissionArea=(val)=>{
    searchForm[val]='';
    searchForm['classIds']='';
    let param = new URLSearchParams();
    param.append('yearly', searchForm.yearly || '');
    param.append('grade', searchForm.grade || '');
    param.append('areaId', searchForm.areaId || '');
    param.append('functionId', menuParams.id || '');
    param.append('roleId', userInfo.roleId || '');
    proxy.$post(baseUrl+'/ft/ftchoose/getSelectPermissions.do', param)
        .then(res => {
            if(res.data.code !==0){
                return proxy.$message.error(res.data.msg);
            }

            
            proxy.$forceUpdate();
            queryListAll= res.data.data || {};

            Object.keys(queryListAll).forEach(key=>{
                queryListAll[key] = (!queryListAll[key] && queryListAll[key]!=0) ? [] : queryListAll[key];
            })
            if(queryListAll['gradeList'] && queryListAll['gradeList'].length&& !searchForm.grade){
                searchForm.grade=queryListAll['gradeList'][0].id;
                getKspcList();
                setTimeout(()=>{
                    getPermissionArea();
                },10)
            }
            if(queryListAll['areaList'] && queryListAll['areaList'].length==1 && !searchForm.areaId){
                searchForm.areaId=queryListAll['areaList'][0].id;
                searchForm.areaName=queryListAll['areaList'][0].name;
                setTimeout(()=>{
                    getPermissionArea();
                },20)
            }
            if(queryListAll['dataRange'] && queryListAll['dataRange'].length && !searchForm.dataRange){
                searchForm.dataRange=queryListAll['dataRange'][0].id;
            }
            if(queryListAll['subjectList']){
                searchForm.subjectId = queryListAll['subjectList'][0]['id'];
                searchForm.subjectName = queryListAll['subjectList'][0]['name'];
            }
            if(val=='testId' ||val=='areaId'){
                getKspcList();
            }

    }, err => {
        console.log(err);
    });
};
/**
 * 考试批次列表
 */
let getKspcList=()=>{
    let param = new URLSearchParams();            
    param.append("paperType",0);
    param.append("grade",searchForm.grade);
    param.append("yearly", searchForm.yearly||''); //学年
    param.append("testType", 1); //1大考 2周统练
    //授课地点
    proxy.$post(baseUrl+'/ft/ftchoose/getSchoolTestsOfCondition.do',param)
        .then(res => {
            if(res.data.code == 0){
                let datas = res.data.data;
                kspcList = res.data.data.schTests;
                searchForm.testIdA =  res.data.data.beforeTestId || '';
                searchForm.testIdB =  datas.compareTestId || '';
            }else{
                proxy.$message.error(res.data.msg);
            }
    }, err => {
        proxy.$message.error(err);
    });
};
let getYears=()=> {
    //获取学年
    proxy.$post(baseUrl + "/ft/campus/getSchoolYearList.do").then(
        res => {
            if (res.data != null && res.data.code == 0) {
                //获取菜单列表
                yearlist = res.data.data;
                yearlist.forEach(element => {
                    if (element.status != null && element.status == 1) {
                        searchForm.yearly = element.value;
                    }
                });
            } else {
                yearlist = [];
            }
        },
        err => {
            proxy.$message.error(err);
        }
    );
};
watch(isSearchAll, (newVal, oldVal)=>{
    if(newVal){
        keyupEnter();
    }
},
{deep: true});
watch(()=>searchForm.grade, (newVal, oldVal)=>{
    if(newVal){
        if(newVal!=11 && searchForm.queryType==5){
            searchForm.queryType = 1;
        }
    }
},
{deep: true});
// export default {
//     name: 'classResultAnalysis',//班级成绩分析
//     data() {
//         return {
//             loading: false,
//             searchForms1: {},
//             direction: 'ltr',//筛选项方向
//             isSearchAll: false,
//             isDel:false,
//             dataList: {
//                 classNumList: []
//             },
//             searchForm: {
//                 yearly: '',
//                 areaId: "",
//                 noIncludelackTest: [],
//                 testIdA: '',
//                 testIdB: '',
//                 grade: '',
//                 grades: '',
//                 queryShow: false,//是否筛选
//                 subjectId: '',
//                 queryType: 1,
//                 queryTypes: '',
//                 scoreType: 0,
//                 scoreTypes: 'a0',
//                 dataRange: '',
//             },
//             searchRules: {
//                 grade: [{required: true, message: '请选择年级', trigger: 'change'}],
//                 dataRange: [{required: true, message: '请选择年级数据范围', trigger: 'change'}],
//                 yearly: [{required: true, message: '请选择学年', trigger: 'change'}],
//                 testIdA: [{required: true, message: '请选择考试批次', trigger: 'change'}],
//                 testIdB: [{required: true, message: '请选择对比批次', trigger: 'change'}],
//                 queryType: [{required: true, message: '请选择查询维度', trigger: 'change'}],
//             },
//             subjectList: [
//                 {id: 100,name: '总分'},
//                 {id: 101,name: '语文'},
//                 {id: 102,name: '数学'},
//                 {id: 103,name: '英语'},
//                 {id: 104,name: '物理'},
//                 {id: 105,name: '化学'},
//                 {id: 106,name: '生物'},
//                 {id: 107,name: '历史'},
//                 {id: 108,name: '地理'},
//                 {id: 109,name: '政治'}
//             ],
//             yearlist: [],//学年列表
//             kspcList: [],
//             areaList: [],
//             menuParams: {},//菜单参数
//             userInfo: {},
//             queryListAll: {//所有查询列表
//                 areaList: []
//             },            
//         }
//     },
//     beforeRouteLeave (to, from, next) { 
//         if (to.name == 'classBoard' || to.name =='stuComDetails' || to.name =='stepStuDetails') {
//         // 根据是否删除操作，进行判断是否需要使用缓存数据
//             to.meta.isUseCache = this.isDel;
//             this.isDel = false;
//         } else {
//             to.meta.isUseCache = false;
//         }       
//         next();    
//     },  
//     activated() {
//         // 因为对list使用keep-alive来缓存组件，所以默认是会使用缓存数据的
//         if (this.$route.meta.isUseCache == true) {
//             // this.getSessionSearch();
//         }
//         this.$route.meta.isUseCache = false;
//     },
//     created(){
//         this.getSessionSearch();
//     }, 
//     components:{
//         classSum1, onlineNum2, avgScore3, compareLast4, classBalance5, classLevel6
//     },
//     watch: {
//         'isSearchAll': {
//             handler: function(val){
//                 if(val){
//                     this.keyupEnter();
//                 }
//             },
//             deep: true
//         },
//         'searchForm.grade': {
//             handler: function(val){
//                 if(val){
//                     if(val!=11 && this.searchForm.queryType==5){
//                         this.searchForm.queryType = 1;
//                     }
//                 }
//             },
//             deep: true
//         }
//     },
//     methods: {
//         getSessionSearch(){
//             let search = JSON.parse(window.sessionStorage.getItem("vuex"))
//             if(JSON.stringify(search.classResultAnalysis.menuParams)!='{}'){
//                 this.menuParams = {...this.menuParams, ...search.classResultAnalysis.menuParams};
//             }    
//             this.getYears();
//             this.getUserInfo();
//         },
//         //回车关闭筛选框
//         keyupEnter(){
//             document.onkeydown = (e) =>{
//                 let body = document.getElementsByTagName('body')[0]
//                 if (e.keyCode === 13 && e.target.baseURI.match(/classResultAnalysis/)) {
//                     console.log('enter')
//                     if(this.isSearchAll){
//                         this.getDataList(); 
//                         //首先把下拉框下拉的东西清掉
//                         let nowEle = document.activeElement;       
//                         let pops = document.querySelectorAll(".el-select-dropdown.el-popper,.el-select.el-popper");
//                         if (pops.length > 0) {
//                             for (let item in pops) {                                  
//                                 if (pops[item] && pops[item].style && pops[item].style.display != 'none') {
//                                     pops[item].style.display = 'none'
//                                     nowEle.click();
//                                 }
//                             }
//                         }                    
//                     }
//                     return false;
//                 }
//             }
//         },
//         //打开查询项
//         openDrawer(){
//             var _this = this;
//             _this.isSearchAll=true;
//         },
//         /**
//          * 班级看板
//          */
//         classTo1(params){
//             this.isDel = true;
//             this.$store.commit('classBoard/setRouteParams', params);
//             this.$router.push({
//                 name:'classBoard',
//                 params: params
//             })
//         },
//         /**
//          *与上次对比 - 学生对比详情
//          * @param routerName 跳转路由的名字
//          * @param type 1原始分 2等级分 学生详情
//          */
//         toStuComDetails(params){
//             this.isDel = true;
//             this.$store.commit(`${params['routerName']}/setRouteParams`, params);
//             this.$router.push({
//                 name:`${params['routerName']}`,
//                 params: params
//             })
//         },
//         //获取用户信息
//         getUserInfo(){
//             let _this = this;
//             this.$axios.get(baseUrl+'/ft/ftchoose/getUserInfo.do')
//                 .then(res => {
//                     if(res.data.code !==0){
//                         _this.$message.error(res.data.msg);
//                         return false;
//                     }
//                     _this.userInfo = res.data || {};
//                     _this.getPermissionArea();
//             }, err => {
//                 this.$message.error(err);
//             });
//         },
//         /**
//          * 改变学年级联批次
//          */
//         handlerYearChange(val){
//             if(!val){
//                 this.searchForm.yearly = '';
//             }
//             this.searchForm.testIdA = '';
//             this.searchForm.testIdB = '';
//             this.getKspcList(); //考试批次
//             this.getPermissionArea('testId');
//         },
//         /**
//          * 获取所有查询列表数据
//          * @functionId 菜单id
//          * @roleId 角色id
//          */
//         getPermissionArea(val){
//             let _this = this;
//             this.searchForm[val]='';
//             this.searchForm['classIds']='';
//             let param = new URLSearchParams();
//             param.append('yearly', this.searchForm.yearly || '');
//             param.append('grade', this.searchForm.grade || '');
//             param.append('areaId', this.searchForm.areaId || '');
//             param.append('functionId', this.menuParams.id || '');
//             param.append('roleId', this.userInfo.roleId || '');
//             this.$axios.post(baseUrl+'/ft/ftchoose/getSelectPermissions.do', param)
//                 .then(res => {
//                     if(res.data.code !==0){
//                         _this.$message.error(res.data.msg);
//                         return false;
//                     }

                   
//                     _this.$forceUpdate();
//                     _this.queryListAll= res.data.data || {};

//                     Object.keys(_this.queryListAll).forEach(key=>{
//                         _this.queryListAll[key] = (!_this.queryListAll[key] && _this.queryListAll[key]!=0) ? [] : _this.queryListAll[key];
//                     })
//                     if(_this.queryListAll['gradeList'] && _this.queryListAll['gradeList'].length&& !this.searchForm.grade){
//                         _this.searchForm.grade=_this.queryListAll['gradeList'][0].id;
//                         _this.getKspcList();
//                         setTimeout(()=>{
//                             _this.getPermissionArea();
//                         },10)
//                     }
//                     if(_this.queryListAll['areaList'] && _this.queryListAll['areaList'].length==1 && !_this.searchForm.areaId){
//                         _this.searchForm.areaId=_this.queryListAll['areaList'][0].id;
//                         _this.searchForm.areaName=_this.queryListAll['areaList'][0].name;
//                         setTimeout(()=>{
//                             _this.getPermissionArea();
//                         },20)
//                     }
//                     if(_this.queryListAll['dataRange'] && _this.queryListAll['dataRange'].length && !_this.searchForm.dataRange){
//                         _this.searchForm.dataRange=_this.queryListAll['dataRange'][0].id;
//                     }
//                     if(_this.queryListAll['subjectList']){
//                         _this.searchForm.subjectId = _this.queryListAll['subjectList'][0]['id'];
//                         _this.searchForm.subjectName = _this.queryListAll['subjectList'][0]['name'];
//                     }
//                     if(val=='testId' ||val=='areaId'){
//                         _this.getKspcList();
//                     }

//             }, err => {
//                 console.log(err);
//             });
//         },
//         /**
//          * 考试批次列表
//          */
//         getKspcList(){
//             let _this = this;
//             let param = new URLSearchParams();            
//             param.append("paperType",0);
//             param.append("grade",this.searchForm.grade);
//             param.append("yearly", this.searchForm.yearly||''); //学年
//             param.append("testType", 1); //1大考 2周统练
//             //授课地点
//             this.$axios.post(baseUrl+'/ft/ftchoose/getSchoolTestsOfCondition.do',param)
//                 .then(res => {
//                     if(res.data.code == 0){
//                         let datas = res.data.data;
//                         _this.kspcList = res.data.data.schTests;
//                         _this.searchForm.testIdA =  res.data.data.beforeTestId || '';
//                         _this.searchForm.testIdB =  datas.compareTestId || '';
//                     }else{
//                         _this.$message.error(res.data.msg);
//                     }
//             }, err => {
//                 this.$message.error(err);
//             });
//         },
//         getYears() {
//             //获取学年
//             let _this = this;
//             this.$axios.post(baseUrl + "/ft/campus/getSchoolYearList.do").then(
//                 res => {
//                     if (res.data != null && res.data.code == 0) {
//                         //获取菜单列表
//                         _this.yearlist = res.data.data;
//                         _this.yearlist.forEach(element => {
//                             if (element.status != null && element.status == 1) {
//                                 _this.searchForm.yearly = element.value;
//                             }
//                         });
//                     } else {
//                         _this.yearlist = [];
//                     }
//                 },
//                 err => {
//                     _this.$message.error(err);
//                 }
//             );
//         },
//         /**
//          * 表格显示列
//          */
//         showTableColumn(){
//             let arr = ['queryType', 'grade','scoreType','subjectId'];
//             this.searchForm.queryShow = true;
//             arr.forEach(item=>{
//                 if(this.searchForm[item]){
//                     this.searchForm[item+'s'] = 'a' +this.searchForm[item];
//                 }
//                 if(this.searchForm[item] == ''){
//                     this.searchForm[item+'s'] = '';
//                 }
//             })
//             this.searchForms1 = JSON.parse(JSON.stringify(this.searchForm));
//         },

//         //参数是否为空值校验
//         paramIsNull(obj){
//             // 浅拷贝
//             var obj2 = {...obj};
//             Object.keys(obj2).forEach((key) => {
//                 if ((obj2[key]&&obj2[key].constructor==Array) ||obj2[key] === undefined || obj2[key] === null || obj2[key] === '' || JSON.stringify(obj2[key]) ==='[Object Object]') {
//                     delete obj2[key];
//                 }
//             });
//             return obj2;
//         },
//         getDataList(searchExport){  
//             let _this = this;
//             let findIndex = this.queryListAll['subjectList'].findIndex((item)=>{ return item.id ==this.searchForm.subjectId});
//             if(findIndex>=0){//当前学年                    
//                 this.searchForm.subjectName = this.queryListAll['subjectList'][findIndex].name;
//             }
            
//             let exportObj ={};
//             if(searchExport==1){
//                 // downloadType 下载类型，1为下载，其他为查询
//                 exportObj ={responseType: 'blob'};
//                 this.searchForm['downloadType'] = 1;
//             }else{
//                 this.searchForm['downloadType'] = 2;
//             }
//             let httpUrl = '/ft/score/analysis/classScoreAnalysis.do';
//             this.$refs['searchRules'].validate((valid) => {
//                 if(valid){
//                     this.isSearchAll = false;
//                     this.loading = true;  
//                     let param = new URLSearchParams();
//                     let datas = JSON.parse(JSON.stringify(this.searchForm));
//                     datas.dataRange = datas.dataRange == "null" ? null : datas.dataRange;
//                     datas.noIncludelackTest = datas.noIncludelackTest.join(",");
//                     let newParam = this.paramIsNull(datas);
//                         Object.keys(newParam).forEach(function(key){
//                         param.append(key, newParam[key]);
//                     }) 
//                     param.append('isMaster', _this.queryListAll['isMaster']);
//                     if(!this.searchForm.classIds){
//                         let classIds = [];
//                         if(this.queryListAll['masterOrTeacherList'] && this.queryListAll['masterOrTeacherList'].length){//没选择班级，默认传全部
//                             this.queryListAll['masterOrTeacherList'].forEach(item=>{
//                                 classIds.push(item.id);
//                             })
//                         }
//                         // classIds.push(36161);
//                         param.append('classIds', classIds.join(','));
//                     }else{
//                         param.append("classIds", this.searchForm.classIds ||'');
//                     }
//                     this.$axios.post(baseUrl + httpUrl, param,exportObj)
//                         .then(res=>{
//                             _this.loading = false;
//                             if(searchExport==1){//导出       
//                                 let headerContent = res.headers['content-disposition'];   
//                                 if(headerContent){
//                                     let filenameStr = headerContent.split('=')[1];
//                                     let blobobj = new Blob([res.data],{type:'application/vnd.ms-excel'});
//                                     downFile(blobobj, decodeURI(filenameStr));
//                                 }
//                             }else{//查询
//                                 if(res.data.code != 0){   
//                                     _this.$message.error(res.data.msg);
//                                     return false;
//                                 }
//                                 _this.dataList = res.data.data;
//                                 if(JSON.stringify(_this.dataList) == "{}"){
//                                     _this.dataList = _this.initList();
//                                 }
//                                 _this.showTableColumn();
//                                 _this.hidePopover();
//                             }

//                         })
//                 }else{
//                     this.$message.error('请输入必填项！');
//                     return false;
//                 }
//             });
//         },
//          //滑动表格 隐藏 popover
//         hidePopover(){
//             this.$nextTick(() => {
//                 let _this = this;
//                 let scroll = document.querySelectorAll("div[class='content'],.el-table .el-table__body-wrapper");
//                 if (scroll && scroll.length) {      
//                     scroll.forEach((item)=>{
//                         // 监听这个dom的scroll事件
//                         item.addEventListener('scroll', () => {
//                             //首先把下拉框下拉的东西清掉
//                             let nowEle = document.activeElement;                     
//                             let select = nowEle.parentNode.parentNode.parentNode;
//                             if (select) {                            
//                                 let pops = document.querySelectorAll(".el-select-dropdown.el-popper,.el-select.el-popper,.el-popover");
//                                 if (pops.length > 0) {
//                                     for (let item in pops) {                                  
//                                         if (pops[item] && pops[item].style && pops[item].style.display != 'none') {
//                                             pops[item].style.display = 'none'
//                                             nowEle.click();
//                                         }
//                                     }
//                                 }
//                             }
//                         }, false)            
//                     })    
//                 }
//             })
//         },
//         initList(){
//             let datas = {};
//             switch (this.searchForm.queryType){
//                 case 1:
//                     datas={
//                         avgMap: {maxScore: 0, className: [], scoreList: []},
//                         classNumList: {classList: [], gradeList: []},
//                         disTableList: {},
//                         xxtMap: {}
//                     }

//                 break;
//                 case 2:
//                     datas={
//                         bareaPercent: {},
//                         bjhLine: {},
//                         lareaPercent: {},
//                         ljhLine: {}
//                     }

//                 break;
//                 case 3:
//                     datas={
//                         bioRank: [],
//                         cmeRank: [],
//                         geoRank: [],
//                         hisRank: [],
//                         mainList: [],
//                         phyRank: [],
//                         polRank: []
//                     }

//                 break;
//                 case 4:
//                     datas={
//                         analyList: {classList: [], gradeList: []},
//                         progressRate:{classList: [], gradeList: []}
//                     }
//                 break;
//                 case 5:
//                 break;
//             }
//             return datas;
//         },
//         handleClose(val){
//             this.isSearchAll = false;
//         }
//     }
// }
</script>
<style lang="scss" scoped>
.con{
    padding:10px 0 0 30px;    
}
</style>